package br.unip.tcc.domotic.controller;

import java.util.Map;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.hibernate.FetchMode;

import br.unip.tcc.domotic.bean.AbstractBean;
import br.unip.tcc.domotic.bean.UserBean;
import br.unip.tcc.domotic.exception.FilterException;
import br.unip.tcc.domotic.exception.ModelException;
import br.unip.tcc.domotic.model.UserModel;

@ManagedBean
@SessionScoped
public class LoginController extends AbstractController<UserBean, UserModel> {
	
	private static final long serialVersionUID = 1L;

	@Override
	public Map<String, FetchMode> getDefaultJoins() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Map<String, String> getDeafautOrdersBy() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void validateFilterSearch() throws FilterException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setBeanId(Integer id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Integer extractBeanId(AbstractBean bean) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getBeanIdName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getUpdateRedirectPage() {
		// TODO Auto-generated method stub
		return null;
	}
	
	public String login(){
		UserBean bean = getBean();
		System.out.println(bean);
		System.out.println(bean.getUserName());
		System.out.println(bean.getUserPassword());
		try {
			getModel().findByExample(bean, null, null);
		} catch (ModelException e) {
			e.printStackTrace();
		}
		FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Foi", "Foi executado");
		FacesContext.getCurrentInstance().addMessage(null, msg);
		return "";
	}

}
